import request from '../utils/request'

export default {
    get(id) {
        return request.get('/sysRole/get', { id })
    },
    page({ current, size, query }) {
        return request.get('/sysRole/pageData',
            {
                current,
                size,
                ...query
            })
    },
    destPageData({ current, size, query }, roleId) {
        return request.get('/sysRole/destPageData',
            {
                current,
                size,
                ...query,
                roleId
            })
    },
    srcPageData({ current, size, query }, roleId) {
        return request.get('/sysRole/srcPageData',
            {
                current,
                size,
                ...query,
                roleId
            })
    },
    addRole(data) {
        return request.post('/sysRole/save', data)
    },
    updateRole(data) {
        return request.post('/sysRole/update', data)
    },
    enableRole(id) {
        return request.get('/sysRole/enableRole', { id })
    },
    disableRole(id) {
        return request.get('/sysRole/disableRole', { id })
    },
    deleteRole(id) {
        return request.get('/sysRole/delete', { id })
    },
    deleteRoleBatch(data) {
        return request.post('/sysRole/deleteBatch', data)
    },
    updateAuth(roleId, authResPack) {
        return request.post(`/sysRole/updateAuth?roleId=${roleId}`, authResPack)
    },
    appListWithAuth(roleId) {
        return request.get('/sysRole/appListWithAuth', { roleId })
    },
    appTreeDataWithAuth(roleId, appCode) {
        return request.get('/sysRole/appTreeDataWithAuth', { appCode, roleId })
    },
    addUsers(roleId, userIds) {
        return request.post(`/sysRole/addUsers?roleId=${roleId}`, userIds)
    },
    removeUsers(roleId, userIds) {
        return request.post(`/sysRole/removeUsers?roleId=${roleId}`, userIds)
    },
}